package com.hatricks.is.util;

import cn.hutool.core.io.unit.DataSizeUtil;
import org.openjdk.jol.info.GraphLayout;

/**
 * @packageName: com.glodon.gcdp.common.utils
 * @className: ObjectUtils
 * @author: yanyuhui y568821795@outlook.com
 * @date: 2024-11-18 16:19
 * @description: 对象工具类
 */
public class ObjectUtils {


    /**
     * 获取对象大小
     *
     * @param o 对象
     * @return 对象大小
     */
    public static String getObjectSize(Object o) {
        long size = GraphLayout.parseInstance(o).totalSize();
        return DataSizeUtil.format(size);
    }

}
